/ / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 / / |                                                                                                             R S I   T r e n d   I n d i c a t o r                                                                                     | 
 
 / / |                                                                             C o p y r i g h t   2 0 2 3 ,   Y o u r N a m e                                                                             | 
 
 / / |                                                                                 h t t p : / / w w w . y o u r w e b s i t e . c o m                                                                         | 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 # p r o p e r t y   c o p y r i g h t   " 2 0 2 3 ,   Y o u r N a m e " 
 
 # p r o p e r t y   l i n k             " h t t p : / / w w w . y o u r w e b s i t e . c o m " 
 
 # p r o p e r t y   v e r s i o n       " 1 . 0 0 " 
 
 # p r o p e r t y   i n d i c a t o r _ s e p a r a t e _ w i n d o w 
 
 # p r o p e r t y   i n d i c a t o r _ b u f f e r s   3 
 
 # p r o p e r t y   i n d i c a t o r _ c o l o r 1   B l u e 
 
 # p r o p e r t y   i n d i c a t o r _ c o l o r 2   R e d 
 
 # p r o p e r t y   i n d i c a t o r _ c o l o r 3   L i m e 
 
 
 
 / / - - -   i n p u t   p a r a m e t e r s 
 
 e x t e r n   i n t   R S I _ P e r i o d   =   1 4 ; 
 
 e x t e r n   i n t   O v e r b o u g h t _ L e v e l   =   7 0 ; 
 
 e x t e r n   i n t   O v e r s o l d _ L e v e l   =   3 0 ; 
 
 
 
 / / - - -   i n d i c a t o r   b u f f e r s 
 
 d o u b l e   T r e n d B u f f e r [ ] ; 
 
 d o u b l e   B u l l i s h B u f f e r [ ] ; 
 
 d o u b l e   B e a r i s h B u f f e r [ ] ; 
 
 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 / / |   C u s t o m   i n d i c a t o r   i n i t i a l i z a t i o n   f u n c t i o n                                                   | 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 i n t   O n I n i t ( ) 
 
     { 
 
       / /   I n d i c a t o r   b u f f e r s   m a p p i n g 
 
       S e t I n d e x B u f f e r ( 0 ,   T r e n d B u f f e r ) ; 
 
       S e t I n d e x B u f f e r ( 1 ,   B u l l i s h B u f f e r ) ; 
 
       S e t I n d e x B u f f e r ( 2 ,   B e a r i s h B u f f e r ) ; 
 
 
 
       / /   I n d i c a t o r   l i n e   l a b e l s 
 
       I n d i c a t o r S h o r t N a m e ( " R S I   T r e n d " ) ; 
 
       S e t I n d e x L a b e l ( 0 ,   " T r e n d " ) ; 
 
       S e t I n d e x L a b e l ( 1 ,   " B u l l i s h " ) ; 
 
       S e t I n d e x L a b e l ( 2 ,   " B e a r i s h " ) ; 
 
 
 
       / /   D e f i n e   i n d i c a t o r   p r o p e r t i e s 
 
       S e t I n d e x S t y l e ( 0 ,   D R A W _ L I N E ) ; 
 
       S e t I n d e x S t y l e ( 1 ,   D R A W _ H I S T O G R A M ) ; 
 
       S e t I n d e x S t y l e ( 2 ,   D R A W _ H I S T O G R A M ) ; 
 
 
 
       r e t u r n ( I N I T _ S U C C E E D E D ) ; 
 
     } 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 / / |   C u s t o m   i n d i c a t o r   i t e r a t i o n   f u n c t i o n                                                             | 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 i n t   O n C a l c u l a t e ( c o n s t   i n t   r a t e s _ t o t a l , 
 
                                 c o n s t   i n t   p r e v _ c a l c u l a t e d , 
 
                                 c o n s t   d a t e t i m e   & t i m e [ ] , 
 
                                 c o n s t   d o u b l e   & o p e n [ ] , 
 
                                 c o n s t   d o u b l e   & h i g h [ ] , 
 
                                 c o n s t   d o u b l e   & l o w [ ] , 
 
                                 c o n s t   d o u b l e   & c l o s e [ ] , 
 
                                 c o n s t   l o n g   & t i c k _ v o l u m e [ ] , 
 
                                 c o n s t   l o n g   & v o l u m e [ ] , 
 
                                 c o n s t   i n t   & s p r e a d [ ] ) 
 
     { 
 
       i n t   l i m i t ; 
 
 
 
       i f ( r a t e s _ t o t a l   <   R S I _ P e r i o d ) 
 
             r e t u r n ( 0 ) ; 
 
 
 
       / /   C a l c u l a t e   R S I   v a l u e s 
 
       l i m i t   =   r a t e s _ t o t a l   -   p r e v _ c a l c u l a t e d ; 
 
       f o r ( i n t   i   =   0 ;   i   <   l i m i t ;   i + + ) 
 
           { 
 
             d o u b l e   r s i V a l u e   =   i R S I ( S y m b o l ( ) ,   0 ,   R S I _ P e r i o d ,   P R I C E _ C L O S E ,   i ) ; 
 
             T r e n d B u f f e r [ i ]   =   r s i V a l u e ; 
 
 
 
             i f ( r s i V a l u e   >   O v e r b o u g h t _ L e v e l ) 
 
                   B u l l i s h B u f f e r [ i ]   =   r s i V a l u e ; 
 
             e l s e 
 
                   B u l l i s h B u f f e r [ i ]   =   0 ; 
 
 
 
             i f ( r s i V a l u e   <   O v e r s o l d _ L e v e l ) 
 
                   B e a r i s h B u f f e r [ i ]   =   r s i V a l u e ; 
 
             e l s e 
 
                   B e a r i s h B u f f e r [ i ]   =   0 ; 
 
           } 
 
 
 
       / /   R e t u r n   v a l u e   t o   r e d r a w 
 
       r e t u r n ( r a t e s _ t o t a l ) ; 
 
     } 
 
 / / + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 
 
 